import Vue from 'vue'
import VueRouter from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

Vue.use(VueRouter)
let routes = [
  {
    path: '/login',
    name: '登录',
    component: () => import('@/views/layout/login'),
  }
]
let requireContext=require.context('./',true,/\.js$/)
requireContext.keys().forEach(fileName => {
  let routerFile=requireContext(fileName)
  routes=[...routes,...(routerFile.default || routerFile)]
})

// 此处参数名一定要为routes，否则读取不到正确的router，
let router = new VueRouter({routes});
router.addRoutes([
  {
    path: '*',
    name: '404',
    component: () => import('@/views/404')
  }
])
export default router
